

function doTabsWithXml(xmlData)
{
	if (window.DOMParser)
    {
	  parser=new DOMParser();
	  xmlDoc=parser.parseFromString(xmlData,"text/xml");
	}
	else // Internet Explorer
	{
	  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	  xmlDoc.async=false;
	  xmlDoc.loadXML(xmlData); 
	}		
	var codeMenu="";
	var codeData="";

	//if (fase)		// esto por archivo propio
	//	var nodes = xmlDoc.childNodes[0].childNodes;  // tab1, tab2, etc.
	//else
	{
		var nodes1 = xmlDoc.childNodes[0].childNodes;  // tab1, tab2, etc.
		var nodeError = nodes1[0].childNodes[0].childNodes[0].childNodes[0].childNodes;
		var errDescr = nodeError[0];
		var errId = nodeError[1];
		
		if (errId.textContent != "0000")
			return errDescr.textContent;
		
		var nodes = nodes1[0].childNodes[0].childNodes[0].childNodes[1].childNodes;
			
		var nodes2 = xmlDoc.getElementsByTagName('detallePadronyDuedaMecenazgo');
	}
	
	var arr = new Array(nodes.length);
	var ih=0;
	var doneTabs = "";
	for(var i=0; i<nodes.length; i++) {
		cnodes = nodes[i];
		cnodename = cnodes.nodeName;
		cnodes = cnodes.childNodes;
		// lo pone si no lo puso antes!
		if (doneTabs.search(":"+cnodename+":") == -1)
		{
			code = getTagNodes(cnodes,ih);
			arr[ih] = code; 
			ih++;
			doneTabs += ":" + cnodename + ":";
		}
		
	}
	return arr;
}

function getTagNodes(cnodes,i)
{
	var codeMenu = '';
	var codeData = '';
	
	codeData = getTagInfo('',cnodes);
	codeMenu = '<a id="tab" href="#" onclick="onclick_Datos(' + i + ')" >' + cnodename + '</a>';	
	return new Array(codeMenu,codeData);
}

function getTagInfo(titulo, cnodes)
{
	var codeInfo = '';
	for (var j=0; j<cnodes.length; j++)
	{
		ccnode = cnodes[j];
		nType = ccnode.nodeType;
		if (nType!=3)
		{
			ccnname = ccnode.nodeName + ': ';
			nChilds = ccnode.childElementCount;
		}
		else
		{
			ccnname = '';
			nChilds = 0;
		}
		
		if (nChilds==0)
		{
			ccvalue = ccnode.textContent;
    		codeInfo += '<li><a href="#"> ' + titulo + ccnname + ccvalue + '</a></li>';
		}
    	else
    	{
    		ccnname = ccnode.nodeName + '-';
    		codeInfo += getTagInfo('   '+ccnname+'-', ccnode.childNodes);
		}
	}
	return codeInfo;
}




